fix: load genesis information from config.yaml#101
Conversation
🤖 Kimi Code ReviewReview SummaryThis PR migrates the genesis configuration from JSON to YAML format, which is a good move for consistency with other configuration files. The changes are generally well-structured, but I've identified several issues that need attention. Critical Issues1. State Root Calculation Bug (High Priority)File: The test
2. Missing Validation (Medium Priority)File: The
Add validation: let mut seen = std::collections::HashSet::new();
for pubkey in &pubkeys {
if !seen.insert(pubkey) {
return Err(D::Error::custom("Duplicate validator pubkey in genesis"));
}
}3. Error Handling Inconsistency (Medium Priority)File: The error handling for genesis configuration is inconsistent:
Consider using proper error propagation with Minor Issues4. Dead Code Warning (Low Priority)File: The 5. Test Data Duplication (Low Priority)File: The test constants 6. Missing Documentation (Low Priority)File: The
Positive Changes✅ Good: Migration from JSON to YAML for consistency with other config files Recommendations
The PR is generally well-structured but needs attention to the state root test and validation concerns before merging. Automated review by Kimi (Moonshot AI) · custom prompt |
🤖 Codex Code ReviewFindings
Questions / assumptions
Looks good overall beyond the configuration/index consistency concerns. Next steps if you want:
Automated review by OpenAI Codex · custom prompt |
🤖 Claude Code ReviewBased on my review of PR #101, here is my code review: PR #101 Code Review: Load genesis from
|
Greptile OverviewGreptile SummaryThis PR fixes a critical consensus issue by standardizing genesis state derivation across all clients. The changes eliminate the dependency on Key changes:
Impact: Confidence Score: 5/5
|
| Filename | Overview |
|---|---|
| crates/common/types/src/genesis.rs | Complete refactor from Genesis struct to GenesisConfig with YAML deserialization, adds comprehensive tests including state root validation |
| bin/ethlambda/src/main.rs | Switches from genesis.json to config.yaml, removes read_validators function, adds genesis info logging |
| crates/common/types/src/state.rs | Simplified State::from_genesis to accept genesis_time directly, initializes checkpoints to default values, added Default derive to Checkpoint |
Sequence Diagram
sequenceDiagram
participant Main as main.rs
participant FS as File System
participant GC as GenesisConfig
participant State as State
participant Store as Store
Main->>FS: Read config.yaml
FS-->>Main: YAML content
Main->>GC: Deserialize YAML to GenesisConfig
GC->>GC: Parse GENESIS_TIME
GC->>GC: Parse GENESIS_VALIDATORS (hex pubkeys)
GC-->>Main: GenesisConfig instance
Main->>Main: Log genesis_time & validator_count
Main->>GC: Call validators()
GC->>GC: Enumerate validators, assign sequential indices (0, 1, 2...)
GC-->>Main: Vec<Validator>
Main->>State: from_genesis(genesis_time, validators)
State->>State: Initialize with default checkpoints
State-->>Main: Genesis State
Main->>Store: from_genesis(backend, genesis_state)
Store-->>Main: Store instance
We're currently loading the genesis timestamp from the
genesis.jsonfile and the validators from theannotated_validators.yamlfile, both generated by lean-quickstart at devnet startup, along with the other network configuration files. However, the other clients load the genesis configuration from theconfig.yamlfile alone, which contains the list of validator pubkeys, ordered by index.We recently had a devnet that failed to finalize due to ethlambda deriving a different genesis state from the other nodes. We suspect this happened because the
annotated_validators.yamlfile had an extra validator. To avoid this happening again, this PR makes ethlambda load the genesis configuration from theconfig.yamlfile, like the other clients.It also adds a setup log with the genesis time and number of validators.